//package com.sskj.aex.v.fragment;
//
//import android.content.Intent;
//import android.graphics.Color;
//import android.os.Bundle;
//import android.support.annotation.Nullable;
//import android.support.v4.content.ContextCompat;
//import android.text.Editable;
//import android.text.InputFilter;
//import android.text.TextUtils;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.widget.AdapterView;
//import android.widget.EditText;
//import android.widget.ListView;
//import android.widget.RadioButton;
//import android.widget.RadioGroup;
//import android.widget.RelativeLayout;
//import android.widget.Spinner;
//import android.widget.TextView;
//
//import com.afollestad.materialdialogs.MaterialDialog;
//import com.scwang.smartrefresh.layout.SmartRefreshLayout;
//import com.scwang.smartrefresh.layout.api.RefreshLayout;
//import com.sskj.ffex.common.ClassicsHeader;
//import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
//import com.sskj.aex.MyAppLication;
//import com.sskj.aex.R;
//import com.sskj.aex.common.Constants;
//import com.sskj.aex.common.MoneyValueFilter;
//import com.sskj.aex.common.adapter.MyBaseAdapter;
//import com.sskj.aex.common.rxbus2.Subscribe;
//import com.sskj.aex.common.rxbus2.ThreadMode;
//import com.sskj.aex.common.widget.ToolBarLayout;
//import com.sskj.aex.m.bean.Currency;
//import com.sskj.aex.m.bean.LevelBean;
//import com.sskj.aex.m.bean.StockBean;
//import com.sskj.aex.m.bean.Time;
//import com.sskj.aex.m.bean.TradeDealBean;
//import com.sskj.aex.m.bean.bean.NewStock;
//import com.sskj.aex.p.fragment.LevelTransactionFragmentPst;
//import com.sskj.aex.utils.CheckUtil;
//import com.sskj.aex.utils.ClickUtil;
//import com.sskj.aex.utils.EditChangeUtil;
//import com.sskj.aex.utils.NumberUtil;
//import com.sskj.aex.utils.TipUtil;
//import com.sskj.aex.utils.ToastUtil;
//import com.sskj.aex.v.activity.LoginActivity;
//import com.sskj.aex.v.activity.MainActivity;
//import com.sskj.aex.v.activity.MarketDetailActivity;
//import com.sskj.aex.v.activity.PayPwdSettingActivity;
//import com.sskj.aex.v.activity.TradeActivity;
//import com.sskj.aex.v.base.BaseFragment;
//import com.sskj.aex.v.widget.mychart.BubbleSeekBar;
//
//import java.text.DateFormat;
//import java.text.DecimalFormat;
//import java.text.SimpleDateFormat;
//import java.util.ArrayList;
//import java.util.List;
//
//import butterknife.BindView;
//import butterknife.ButterKnife;
//import butterknife.OnClick;
//import io.reactivex.Flowable;
//
//
///**
// * 杠杆交易
// * create by Hey at 2018/4/26 9:14
// */
//
//public class LevelTransactionFragment extends BaseFragment<MainActivity, LevelTransactionFragmentPst> implements OnRefreshListener {
//
//    private static String TAG = "LevelTransactionFragment";
//    @BindView(R.id.toolBar)
//    ToolBarLayout mToolBar;
//    @BindView(R.id.transaction_lsit)
//    ListView mTransactionList;
//    @BindView(R.id.smart_refresh)
//    SmartRefreshLayout mSmartRefresh;
//
//    private HeaderViewHolder mHeaderViewHolder;
//    private MyBaseAdapter<TradeDealBean> mAdapter;
//    private View mItem_foot;
//    /**
//     * 价格类型 ： 1: 市价   ；   2 ： 限价
//     * 默认 限价
//     */
//    private int mType = 1;
//    /**
//     * 下单需要的数据
//     */
//    private StockBean mStockBean;
//    /**
//     * 当前股票的当前价格
//     */
//    private double mCurrentPriceD;
//    DecimalFormat mFormat = new DecimalFormat("0.0000");
//    DateFormat dateFormat = new SimpleDateFormat("HH:mm MM/dd");
//    /**
//     * 计算的交易额
//     */
//    private double mSumPrice;
//    private String name = "";
//    private double price;
//    private String code = "";
//    private double maxNum; //可输入的最大数量
//    private double minNum; //可输入的最小数量
//    private int minDealNum; //可交易的最小数量
//    private MaterialDialog customTip;
//    private String unit = "USDT";
//    private double leverage = 20; //杠杆
//    private double shouPer; //手续费
//    private String baoPer = "100%";
//    /**
//     * 当前币种的浮动点差价格
//     */
//    private double mSpreadPrice;
//    private double unitPrice;
//    private int mStoplossMax;
//    private int mStopwinMax;
//
//    @Override
//    public int getLayoutId() {
//        return R.layout.fragment_level_transaction;
//    }
//
//    @Override
//    public LevelTransactionFragmentPst getPresenter() {
//        return new LevelTransactionFragmentPst();
//    }
//
//    //    public int status = 0;//0 买入，1 卖出，
//    public boolean isLimitPrice = true; //是否市价 默认非市价
//    private String wallet = "0.00";
//
//
//    @Override
//    public void onHiddenChanged(boolean hidden) {
//        super.onHiddenChanged(hidden);
//        if (!hidden) {
//            if (!TextUtils.isEmpty(MyAppLication.getMobile()) && MyAppLication.isLogin()) {
//                mPresenter.getUserInfo();
//                if (!TextUtils.isEmpty(code)) {
//                    mPresenter.getLeveRange(code);
////                    mPresenter.requestOrderList(code);
//                }
//            }
//        }
//    }
//
//    @Override
//    public void onResume() {
//        super.onResume();
//        if (!isHidden() && !TextUtils.isEmpty(MyAppLication.getMobile()) && MyAppLication.isLogin()) {
//            mPresenter.getUserInfo();
//            if (!TextUtils.isEmpty(code)) {
//                mPresenter.getLeveRange(code);
////                mPresenter.requestOrderList(code);
//            }
//        }
//    }
//
//
//    @Override
//    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
//        super.onViewCreated(view, savedInstanceState);
//        ClassicsHeader classicsHeader = new ClassicsHeader(getActivity());
//        classicsHeader.setBackgroundColor(getResources().getColor(R.color.background));
//        mSmartRefresh.setRefreshHeader(classicsHeader);
//        mSmartRefresh.setEnableLoadMore(false);
//        mSmartRefresh.setOnRefreshListener(this);
//        mToolBar.setRightButtonIcon(getResources().getDrawable(R.mipmap.icon_a_nor));
//
//        mToolBar.setRightButtonOnClickLinster(view12 -> { //跳转股票详情
//            if (mActivity.mCurrentStock != null) {
//                switch (mActivity.mCurrency) {
//                    case TIME:
//                        MarketDetailActivity.start(getActivity(), (NewStock) mActivity.mCurrentStock, 1);
//                        break;
//                    case BTC:
//                        MarketDetailActivity.start(getActivity(), (NewStock) mActivity.mCurrentStock, 1);
//                        break;
//                }
//            }
//        });
//
//        mToolBar.setLeftButtonOnClickLinster(view1 -> mActivity.openDrawerLayout());
//
//        View item_head = LayoutInflater.from(mActivity).inflate(R.layout.layout_head_view, null);
//        mItem_foot = LayoutInflater.from(mActivity).inflate(R.layout.layout_foot_view, null);
//
//        mHeaderViewHolder = new HeaderViewHolder(item_head);
//        mTransactionList.addHeaderView(item_head);
//        mAdapter = new MyBaseAdapter<TradeDealBean>(new MyBaseAdapter.initView<TradeDealBean>() {
//            @Override
//            public View initItenView(int position, View convertView, ViewGroup parent, TradeDealBean obj) {
//                if (convertView == null) {
//                    convertView = LayoutInflater.from(mActivity).inflate(R.layout.item_transaction_order_layout, null);
//                }
//                TextView itemPrice = convertView.findViewById(R.id.item_price);
//                TextView itemPriceValue = convertView.findViewById(R.id.item_price_value);
//                TextView itemFinalPrice = convertView.findViewById(R.id.item_final_price);
//                TextView itemFinalPriceVlaue = convertView.findViewById(R.id.item_final_price_value);
//                TextView itemCount = convertView.findViewById(R.id.item_count);
//                TextView itemCountVlaue = convertView.findViewById(R.id.item_count_value);
//                TextView itemTitle = convertView.findViewById(R.id.item_title);
//                TextView itemType = convertView.findViewById(R.id.item_type);
//
//                if (obj.getOtype() == 1) {
//                    itemType.setText(App.INSTANCE.getString(R.string.strLevelTransactionFragment208));
//                    itemType.setTextColor(getResources().getColor(R.color.market_up));
//                } else {
//                    itemType.setTextColor(getResources().getColor(R.color.market_down));
//                    itemType.setText(App.INSTANCE.getString(R.string.strLevelTransactionFragment209));
//                }
//                itemPrice.setText(getString(R.string.transaction_order_item_price));
//                itemFinalPrice.setText(getString(R.string.transaction_order_item_final_price));
//                itemCount.setText(getString(R.string.transaction_order_item_count));
//
//                itemPriceValue.setText(obj.buyprice);
//
//                itemCountVlaue.setText(obj.buynum);
//                itemFinalPriceVlaue.setText(obj.sellprice);
//                itemTitle.setText(obj.pname + "  " + dateFormat.format(obj.selltime * 1000));
//
//                return convertView;
//            }
//        });
//
//        mTransactionList.setAdapter(mAdapter);
//        mStockBean = new StockBean();
//        upDate();
//    }
//
//    public void upDate() {
//        updateUserTitle();
//        updateCoinData();
//        if (mActivity.mCurrentStock != null) {
//            mActivity.mTransactionFragmentUp = true;
//            updateSaleAndSold();
//            mHeaderViewHolder.mTransctionPriceTextView.setVisibility(isLimitPrice ? View.VISIBLE : View.GONE);
//            mHeaderViewHolder.rlEditPrice.setVisibility(isLimitPrice ? View.GONE : View.VISIBLE);
//            mHeaderViewHolder.mTransctionPriceEditText.setText(String.valueOf(price));
//            String type;
//            if (name.contains("_")) {
//                String[] split = name.split("_");
//                unit = split[1];
//                type = split[0];
//            } else if (name.contains("/")) {
//                String[] split = name.split("/");
//                unit = split[1];
//                type = split[0];
//            } else {
//                type = name;
//            }
//
////            mHeaderViewHolder.mSpinner.setSelection(mType == 2 ? 0 : 1);
//            mHeaderViewHolder.mTransactionType.setText(type);  // 类型购买数量后面跟的   BTC
//            mToolBar.setTitle(name.replace("_", "/"));
//            mHeaderViewHolder.mTransctionSumEditText.getText().clear();
//            mHeaderViewHolder.mTransactionSeekBar.setCurrentProgress(0f);
//            updateCountText(0.0);
//            mHeaderViewHolder.mTransactionSeekBar.getConfigBuilder().max((int) maxNum).build();
//            mHeaderViewHolder.mTransactionSeekBar.getConfigBuilder().min((int) minNum).build();
//        }
//    }
//
//    private void updateCountText(double money) {
////        mHeaderViewHolder.mTransactionCount.setText(getString(R.string.transaction_count) + mFormat.format(mSumPrice) + unit);
//        mHeaderViewHolder.mTransactionCount.setText(getString(R.string.transaction_count) + " " + mFormat.format(money) + " " + unit);
//    }
//
//    private void updateSaleAndSold() {
//        if (mActivity.status == 0) { //买入
//            if (mHeaderViewHolder.mRadioGroup.getCheckedRadioButtonId() != R.id.price_type_a) {
//                mHeaderViewHolder.mRadioGroup.check(R.id.price_type_a);
//            }
//            mHeaderViewHolder.mTransactionInput.setVisibility(View.VISIBLE);
//            mHeaderViewHolder.mTransactionInput.setText(R.string.transaction_input_btn);
//            mHeaderViewHolder.mTransactionInput.setBackground(getResources().getDrawable(R.drawable.shape_rectangle_green_rc));
//            mHeaderViewHolder.mTransactionOutput.setVisibility(View.GONE);
//            mHeaderViewHolder.mTransctionSumEditText.setHint(App.INSTANCE.getString(R.string.strLevelTransactionFragment219) + minDealNum);
//        } else { //卖出
//            if (mHeaderViewHolder.mRadioGroup.getCheckedRadioButtonId() != R.id.price_type_b) {
//                mHeaderViewHolder.mRadioGroup.check(R.id.price_type_b);
//            }
//            mHeaderViewHolder.mTransactionInput.setVisibility(View.GONE);
//            mHeaderViewHolder.mTransactionOutput.setVisibility(View.VISIBLE);
//            mHeaderViewHolder.mTransactionOutput.setText(R.string.transaction_output_btn);
//            mHeaderViewHolder.mTransactionOutput.setBackground(getResources().getDrawable(R.drawable.shape_rectangle_red_rc));
//            mHeaderViewHolder.mTransctionSumEditText.setHint(App.INSTANCE.getString(R.string.strLevelTransactionFragment219) + minDealNum);
//        }
//    }
//
//
//    private void updateCoinData() {
//        if (mActivity.mCurrentStock instanceof NewStock) { //五大币
//            NewStock stock = (NewStock) mActivity.mCurrentStock;
//            name = stock.getCode().toUpperCase();
////            switchPrice(stock.getBuy(), stock.getSell());
//            mCurrentPriceD = price = Double.valueOf(stock.getPrice());
//            code = stock.getCode();
//            mPresenter.getLeveRange(code);
//            updateTopView(true);
//        }
////        mPresenter.requestOrderList(code);
//    }
//
//    public void updateTopView(boolean flag) {
//        NewStock stock = (NewStock) mActivity.mCurrentStock;
//        if (stock.getChange() > 0) {
//            mHeaderViewHolder.mTransactionStockChangeValue.setTextColor(getResources().getColor(R.color.market_up));
//            mHeaderViewHolder.mTransactionStockPrice.setTextColor(getResources().getColor(R.color.market_up));
//            mHeaderViewHolder.mTransactionStockChangeValue.setText("+" + stock.getChangeRate());
//        } else {
//            mHeaderViewHolder.mTransactionStockChangeValue.setTextColor(getResources().getColor(R.color.market_down));
//            mHeaderViewHolder.mTransactionStockPrice.setTextColor(getResources().getColor(R.color.market_down));
//            mHeaderViewHolder.mTransactionStockChangeValue.setText(String.valueOf(stock.getChangeRate()));
//        }
//        mHeaderViewHolder.mTransactionStockPrice.setText(NumberUtil.keepPoint4(stock.getPrice()));  //推送价钱
//        if (flag) mHeaderViewHolder.mTransctionPriceTextView.setText(stock.getPrice());  // 输入框价格
//        mHeaderViewHolder.mTransactionStockHightPrice.setText(mFormat.format(stock.getHigh()));
//        mHeaderViewHolder.mTransactionStockLowPrice.setText(mFormat.format(stock.getLow()));
//        mHeaderViewHolder.mTransactionApproximate.setText(String.format(getString(R.string.approximate), NumberUtil.keep2(stock.getCnyPrice())));
//
//    }
//
//    /**
//     * 切换显示价格
//     *
//     * @param buyPrice  买价
//     * @param sellPrice 卖价
//     */
//
//    private void switchPrice(String buyPrice, String sellPrice) {
//        if (mActivity.status == 0) { //买入
//            mCurrentPriceD = price = Float.parseFloat(sellPrice);
//        } else {
//            mCurrentPriceD = price = Float.parseFloat(buyPrice);
//        }
//    }
//
//    private void updateUserTitle() {
//        if (MyAppLication.isLogin()) { //有登陆
//            if (mHeaderViewHolder != null) {
////                mHeaderViewHolder.mTransactionItemBalance.setText(wallet);  // 用户可用USDT
//                mHeaderViewHolder.mTransactionUserBalance.setText(String.format(getString(R.string.balance), wallet) + " USDT");
//            }
//        } else { //没登录
//            if (mHeaderViewHolder != null) {
//                wallet = "0.00";
////                mHeaderViewHolder.mTransactionItemBalance.setText("0.000");
//                mHeaderViewHolder.mTransactionUserBalance.setText(String.format(getString(R.string.balance), String.valueOf("0.00")) + " USDT");
//                if (mTransactionList.getFooterViewsCount() <= 0) {
//                    mTransactionList.addFooterView(mItem_foot);
//                }
//                mAdapter.clear();
//            }
//        }
//    }
//
//    /**
//     * 用户交易订单列表获取成功
//     *
//     * @param rest
//     */
//    public void onOrderListResponseSuccess(List<TradeDealBean> rest) {
//        if (rest == null) {
//            if (mTransactionList.getFooterViewsCount() <= 0) {
//                mTransactionList.addFooterView(mItem_foot);
//            }
//            mAdapter.setList(new ArrayList<>());
//
//        } else {
//            Flowable.fromIterable(rest)
//                    .take(5)
//                    .toList()
//                    .subscribe((tradeDealBeans, throwable) -> {
//                        mTransactionList.removeFooterView(mItem_foot);
//                        mAdapter.setList(tradeDealBeans);
//                    });
//        }
//
//    }
//
//    @Override
//    public void onRefresh(RefreshLayout refreshLayout) {
//        mSmartRefresh.finishRefresh();
////        mPresenter.requestOrderList(code);
//        mPresenter.getLeveRange(code);
//        mPresenter.getUserInfo();
//    }
//
//    public void updateWallet(String wallet) {
//        this.wallet = wallet;
//        upDate();
//    }
//
//    public void onCreateOrderSuccess(boolean isWeituo) {
//        //止盈止损初始化
//        mHeaderViewHolder.mTransactionStopLossInput.setText("");
//        mHeaderViewHolder.mTransactionTargetProfitInput.setText("");
//        startActivity(new Intent(getActivity(), TradeActivity.class).putExtra("index", isWeituo ? 1 : 0));
//    }
//
//    /**
//     * 币种杠杆信息
//     *
//     * @param levelBean
//     */
//    public void upDateLevel(LevelBean levelBean) {
//        unitPrice = levelBean.getVar_price();
//        leverage = Double.valueOf(levelBean.getLeverage());
//        baoPer = levelBean.getTrans_ware();
//        shouPer = Double.valueOf(levelBean.getTrans_fee().replace("%", "")) / 100;
//        mSpreadPrice = levelBean.getSpread() * levelBean.getVar_price();
//        minNum = 0;
//        minDealNum = levelBean.getNum_min();
////        if (minDealNum == 0) {
////            minDealNum = 1;
////        }
//        String trim = mHeaderViewHolder.mTransctionPriceTextView.getText().toString().trim();
//
//        if (mActivity.status == 0) {
//            if (TextUtils.isEmpty(trim)) {
//                mCurrentPriceD = Double.valueOf(trim) + mSpreadPrice;
//            }
//            mHeaderViewHolder.mTransctionSumEditText.setHint(App.INSTANCE.getString(R.string.strLevelTransactionFragment219) + minDealNum);
//        } else {
//            if (TextUtils.isEmpty(trim)) {
//                mCurrentPriceD = Double.valueOf(trim) - mSpreadPrice;
//            }
//            mHeaderViewHolder.mTransctionSumEditText.setHint(App.INSTANCE.getString(R.string.strLevelTransactionFragment219) + minDealNum);
//        }
//
//        calcuMostNum();
//
//        mHeaderViewHolder.mTransactionSeekBar.getConfigBuilder().max((int) maxNum).build();
//        mHeaderViewHolder.mTransactionSeekBar.getConfigBuilder().min((int) minNum).build();
//        mStoplossMax = (int) levelBean.getStoploss();
//        mStopwinMax = (int) levelBean.getStopwin();
//        mHeaderViewHolder.mTransactionStopLossInput.setHint("<=" + levelBean.getStoploss());
//        mHeaderViewHolder.mTransactionTargetProfitInput.setHint("<=" + levelBean.getStopwin());
//    }
//
//
//    public class HeaderViewHolder implements RadioGroup.OnCheckedChangeListener {
//        //        @BindView(R.id.transaction_item_balance)
////        TextView mTransactionItemBalance;
//        @BindView(R.id.top_stock_price)
//        TextView mTransactionStockPrice;  //推送价钱
//        @BindView(R.id.top_stock_change_value)
//        TextView mTransactionStockChangeValue;
//        @BindView(R.id.top_stock_low_price)
//        TextView mTransactionStockLowPrice;
//        @BindView(R.id.top_stock_hight_price)
//        TextView mTransactionStockHightPrice;
//        @BindView(R.id.transaction_approximate_top)
//        TextView mTransactionApproximate;
//        @BindView(R.id.risk_ratio)
//        TextView mRiskRatio;
//        @BindView(R.id.transction_price_editText)
//        EditText mTransctionPriceEditText;
//        @BindView(R.id.transction_price_textView)
//        TextView mTransctionPriceTextView;  // 输入框价钱
//        @BindView(R.id.transction_increase_price)
//        TextView mTransctionIncreasePrice;
//        @BindView(R.id.transction_decrease_price)
//        TextView mTransctionDecreasePrice;
//        @BindView(R.id.transaction_count)
//        TextView mTransactionCount;
//        @BindView(R.id.transction_sum_editText)
//        EditText mTransctionSumEditText;
//        @BindView(R.id.transaction_type)
//        TextView mTransactionType;
//        @BindView(R.id.transaction_user_balance)
//        TextView mTransactionUserBalance;
//        @BindView(R.id.transcation_seekbar)
//        BubbleSeekBar mTransactionSeekBar;
//        @BindView(R.id.transcation_stop_loss_input)
//        EditText mTransactionStopLossInput;
//        @BindView(R.id.transcation_target_profit_input)
//        EditText mTransactionTargetProfitInput;
//        //        @BindView(R.id.stop_loss_value)
////        TextView mStopLossValue;
////        @BindView(R.id.target_profit_value)
////        TextView mTargetProfitValue;
//        @BindView(R.id.transaction_input)
//        TextView mTransactionInput;  // 做多
//        @BindView(R.id.transaction_output)
//        TextView mTransactionOutput;
//        @BindView(R.id.transaction_history_all)
//        TextView mTransactionHistoryAll;  // 全部  图标
//        @BindView(R.id.radioGroup)
//        RadioGroup mRadioGroup;
//        @BindView(R.id.price_type_a)
//        RadioButton mRadioBTTypeA;
//        @BindView(R.id.price_type_b)
//        RadioButton mRadioBTTypeB;
//        @BindView(R.id.tv_detail_title_type)
//        TextView tvDetailTitleType;
//        @BindView(R.id.spinner)
//        Spinner mSpinner;
//        @BindView(R.id.rlEditPrice)
//        RelativeLayout rlEditPrice;
//
//        public HeaderViewHolder(View headerView) {
//            ButterKnife.bind(this, headerView);
//            mRadioGroup.setOnCheckedChangeListener(this);
//            if (mActivity.mUserInfo != null) {
////                mTransactionItemBalance.setText(mActivity.mUserInfo.wallone);
//                mTransactionUserBalance.setText(String.format(getString(R.string.balance), mActivity.mUserInfo.wallone) + " USDT");
//
//            }
//            //查看全部交易记录
//            ClickUtil.click(mTransactionHistoryAll, () -> {
//                if (MyAppLication.isLogin()) {
//                    startActivity(new Intent(mActivity, TradeActivity.class));
//                } else {
//                    startActivity(new Intent(mActivity, LoginActivity.class));
//                }
//            });
//            //购买金额滑杆
//            mTransactionSeekBar.setOnProgressChangedListener(new BubbleSeekBar.OnProgressChangedListener() {
//                @Override
//                public void onProgressChanged(BubbleSeekBar bubbleSeekBar, int progress, float progressFloat, boolean fromUser) {
//                    if (fromUser) {
//                        double num = progress;
//                        if (num <= minNum) {
//                            num = minNum;
//
//                        } else if (num >= maxNum) {
//                            num = maxNum;
//                        }
//                        mTransctionSumEditText.setText(((int) num) + "");
//                    }
//                }
//
//                @Override
//                public void getProgressOnActionUp(BubbleSeekBar bubbleSeekBar, int progress, float progressFloat) {
//                }
//
//                @Override
//                public void getProgressOnFinally(BubbleSeekBar bubbleSeekBar, int progress, float progressFloat, boolean fromUser) {
//                }
//            });
//            EditChangeUtil.onChange(mTransactionStopLossInput, s -> {
//                if (!TextUtils.isEmpty(s.toString())) {
//                    Double aDouble = Double.valueOf(s.toString());
//                    if (aDouble > mStoplossMax) {
//                        String max = String.valueOf(mStoplossMax);
//                        mTransactionStopLossInput.setText(String.valueOf(mStoplossMax));
//                        mTransactionStopLossInput.setSelection(max.length());
//                    }
//                }
//            });
//            EditChangeUtil.onChange(mTransactionTargetProfitInput, s -> {
//                if (!TextUtils.isEmpty(s.toString())) {
//                    Double aDouble = Double.valueOf(s.toString());
//                    if (aDouble > mStopwinMax) {
//                        String max = String.valueOf(mStopwinMax);
//                        mTransactionTargetProfitInput.setText(max);
//                        mTransactionTargetProfitInput.setSelection(max.length());
//                    }
//                }
//            });
//
//
////            //止盈滑杆
////            mTransactionTargetProfitSeekBar.setOnProgressChangedListener(new BubbleSeekBar.OnProgressChangedListener() {
////                @Override
////                public void onProgressChanged(BubbleSeekBar bubbleSeekBar, int progress, float progressFloat, boolean fromUser) {
////                    mTargetProfitValue.setText(String.valueOf(progress));
////                }
////
////                @Override
////                public void getProgressOnActionUp(BubbleSeekBar bubbleSeekBar, int progress, float progressFloat) {
////                }
////
////                @Override
////                public void getProgressOnFinally(BubbleSeekBar bubbleSeekBar, int progress, float progressFloat, boolean fromUser) {
////                }
////            });
//            //止损滑杆
////            mTransactionStopLossSeekBar.setOnProgressChangedListener(new BubbleSeekBar.OnProgressChangedListener() {
////                @Override
////                public void onProgressChanged(BubbleSeekBar bubbleSeekBar, int progress, float progressFloat, boolean fromUser) {
////                    mStopLossValue.setText(String.valueOf(progress));
////                }
////
////                @Override
////                public void getProgressOnActionUp(BubbleSeekBar bubbleSeekBar, int progress, float progressFloat) {
////                }
////
////                @Override
////                public void getProgressOnFinally(BubbleSeekBar bubbleSeekBar, int progress, float progressFloat, boolean fromUser) {
////                }
////            });
//
//            EditChangeUtil.onChange(mTransctionPriceEditText, s -> {
//                if (mActivity.status == 0) {
//                    mCurrentPriceD = Double.parseDouble(TextUtils.isEmpty(s.toString()) ? "0" : s.toString()) + mSpreadPrice;
//                } else {
//                    mCurrentPriceD = Double.parseDouble(TextUtils.isEmpty(s.toString()) ? "0" : s.toString()) - mSpreadPrice;
//                }
//                if (mCurrentPriceD <= 0) {
//                    mCurrentPriceD = mSpreadPrice;
//                }
//                if (TextUtils.isEmpty(s.toString()) || Double.isInfinite(maxNum) || Double.isNaN(maxNum)) {
//                    maxNum = 0;
//                } else {
//                    calcuMostNum();
//                }
//                mHeaderViewHolder.mTransactionSeekBar.getConfigBuilder().max((int) maxNum).build();
//                if (!TextUtils.isEmpty(mTransctionSumEditText.getText().toString().trim())) {
//                    //交易额 计算公式 : 最新价*购买数量/20
//                    double valueD = Double.valueOf(mTransctionSumEditText.getText().toString().trim());
//
//                    mSumPrice = calcuAllPrice(mCurrentPriceD, valueD);
//                    updateCountText(mSumPrice);
////                    mTransactionCount.setText(getString(R.string.transaction_count) + mFormat.format(mSumPrice) + unit);
//                }
//            });
//
////            mTransctionSumEditText.setOnFocusChangeListener((view, b) -> {
////                if (b) {
////                    String currentPrice = null;
////                    if (!isLimitPrice) {
////                        currentPrice = mTransctionPriceEditText.getText().toString().trim();
////
////                    } else {
////                        currentPrice = price + "";
////                    }
////                    if (!TextUtils.isEmpty(currentPrice)) {
////                        mCurrentPriceD = Double.valueOf(currentPrice);
////                        maxNum = Double.parseDouble(wallet) * 20 / mCurrentPriceD;
////                        mHeaderViewHolder.mTransactionSeekBar.getConfigBuilder().max((int) maxNum).build();
////                    }
////                }
////            });
//            mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
//                @Override
//                public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
//                    if (position == 0) {
//                        isLimitPrice = true;
//                        mType = 1;
//                        mCurrentPriceD = TextUtils.isEmpty(mHeaderViewHolder.mTransctionPriceEditText.getText().toString().trim()) ? 0 : Double.parseDouble(mHeaderViewHolder.mTransctionPriceEditText.getText().toString().trim());
//                    } else {
//                        isLimitPrice = false;
//                        mCurrentPriceD = price;
//                        mType = 2;
//                    }
//                    upDate();
//                }
//
//                @Override
//                public void onNothingSelected(AdapterView<?> parent) {
//
//                }
//            });
//
//            mTransctionPriceEditText.setFilters(new InputFilter[]{new MoneyValueFilter().setDigits(4)});
//            EditChangeUtil.onChange(mTransctionSumEditText, editable -> {
//                if (!TextUtils.isEmpty(editable.toString())) {
//                    double valueD = formatDouble(editable);
//                    if (valueD > maxNum) { //大于最大数量
//                        mTransactionSeekBar.setCurrentProgress((int) maxNum);
//                        mTransctionSumEditText.setText(String.valueOf((int) maxNum));
//                        mTransctionSumEditText.setSelection(String.valueOf((int) maxNum).length());
//                    } else if (valueD < minNum) { //小于最小数量
//                        mTransactionSeekBar.setCurrentProgress((int) minNum);
//                    } else { //数量正常
//                        //交易额 计算公式 : 最新价*购买数量/20
//                        mSumPrice = calcuAllPrice(mCurrentPriceD, valueD);
//                        updateCountText(mSumPrice);
////                        mTransactionCount.setText(getString(R.string.transaction_count) + mFormat.format(mSumPrice) + unit);
//                        mTransactionSeekBar.setCurrentProgress((int) valueD);
//                    }
//                } else { //数量为空，使用最小数量
//                    mSumPrice = calcuAllPrice(mCurrentPriceD, minNum);
//                    mTransactionCount.setText(getString(R.string.transaction_count) + mFormat.format(mSumPrice) + unit);
//                    mTransactionSeekBar.setCurrentProgress((int) minNum);
//                }
//            });
//            ClickUtil.click(mTransactionInput, () -> { //买入（买涨）
//                mStockBean.otype = 1;
//                placeOrder();
//            });
//            ClickUtil.click(mTransactionOutput, () -> { //卖出（买跌）
//                mStockBean.otype = 2;
//                placeOrder();
//            });
//            ClickUtil.click(mRiskRatio, () -> {
//                customTip = TipUtil.customTip(getActivity(), App.INSTANCE.getString(R.string.strLevelTransactionFragment241), App.INSTANCE.getString(R.string.strLevelTransactionFragment242) + baoPer + App.INSTANCE.getString(R.string.strLevelTransactionFragment243), App.INSTANCE.getString(R.string.strLevelTransactionFragment244));
//            });
//
//
//        }
//
//
//        private void placeOrder() {
//            if (MyAppLication.isLogin()) {
//                Double userBalance = Double.valueOf(mActivity.mUserInfo.wallone);
//                Double sumVlaue = mSumPrice;
//                if (userBalance < sumVlaue) {
//                    ToastUtil.showShort(App.INSTANCE.getString(R.string.strLevelTransactionFragment245));
//                    return;
//                }
//
//
//                String num = mTransctionSumEditText.getText().toString().trim();
//                if (TextUtils.isEmpty(num)) {
//                    ToastUtil.showShort(App.INSTANCE.getString(R.string.strLevelTransactionFragment246));
//                    return;
//                }
//                mStockBean.buynum = Integer.valueOf(num);
//
//                if (mStockBean.buynum <= 0) {
//                    ToastUtil.showShort(App.INSTANCE.getString(R.string.strLevelTransactionFragment247));
//                    return;
//                }
//                if (mStockBean.buynum < minDealNum) {
//                    ToastUtil.showShort(App.INSTANCE.getString(R.string.strLevelTransactionFragment248) + minDealNum);
//                    return;
//                }
//                if (TextUtils.isEmpty(mActivity.mUserInfo.tpwd)) {
//                    ToastUtil.showShort(App.INSTANCE.getString(R.string.strLevelTransactionFragment249));
//                    startActivity(new Intent(mActivity, PayPwdSettingActivity.class));
//                    return;
//                }
//
//                mStockBean.type = mType;
//                if (mType == 2) { //限价，选择用户输入的价格
//                    if (TextUtils.isEmpty(mHeaderViewHolder.mTransctionPriceEditText.getText().toString().trim())) {
//                        ToastUtil.showShort(App.INSTANCE.getString(R.string.strLevelTransactionFragment250));
//                        return;
//                    } else if (Double.valueOf(mHeaderViewHolder.mTransctionPriceEditText.getText().toString().trim()) <= 0) {
//                        ToastUtil.showShort(App.INSTANCE.getString(R.string.strLevelTransactionFragment251));
//                        return;
//                    }
//                    mStockBean.newprice = mTransctionPriceEditText.getText().toString().trim();
//                } else { //市价，选择股票最新的价格
//                    mStockBean.newprice = mTransctionPriceTextView.getText().toString().trim();
//                }
//                if (mActivity.mCurrency == Currency.BTC) {
//                    mStockBean.shopname = ((NewStock) mActivity.mCurrentStock).getCode();
//                } else {
//                    mStockBean.shopname = ((Time) mActivity.mCurrentStock).getMark();
//                }
//                String stoploss = mHeaderViewHolder.mTransactionStopLossInput.getText().toString().trim();
//                String stopwin = mHeaderViewHolder.mTransactionTargetProfitInput.getText().toString().trim();
//                mStockBean.stoploss = TextUtils.isEmpty(stoploss) ? 0 : Integer.valueOf(stoploss);
//                mStockBean.stopwin = TextUtils.isEmpty(stopwin) ? 0 : Integer.valueOf(stopwin);
//                //                        getActivity().startActivityForResult(new Intent(getActivity(), PayPwdInputActivity.class).putExtra("stock_data", mStockBean), Constants.PAY_PWD_INPUT);
//
//                int type;
//                if (mStockBean.otype == 1) {//做多
//                    type = mType == 1 ? 0 : 1;
//                } else {
//                    type = mType == 1 ? 2 : 3;
//                }
//                TipUtil.getTip(mActivity, type, mStockBean.newprice, String.valueOf(mStockBean.stopwin), String.valueOf(mStockBean.stoploss), String.valueOf(mStockBean.buynum), () -> {
//                    if (mActivity.mCurrency == Currency.TIME) {
//                        mPresenter.createOrder(mStockBean, true, mType == 2);
//                    } else {
//                        mPresenter.createOrder(mStockBean, false, mType == 2);
//                    }
//                }).show();
//                return;
//
//            } else {
////                ToastUtil.showShort(App.INSTANCE.getString(R.string.strLevelTransactionFragment253));
//                startActivity(new Intent(mActivity, LoginActivity.class));
//            }
//        }
//
//
//        @Override
//        public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
//            switch (checkedId) {
//                case R.id.price_type_a://买入
//                    mActivity.status = 0;
//
//                    mHeaderViewHolder.mTransactionSeekBar.setThumbColor(ContextCompat.getColor(mActivity, R.color.market_up));
//                    mHeaderViewHolder.mTransactionSeekBar.setSecondTrackColor(ContextCompat.getColor(mActivity, R.color.market_up));
//                    mHeaderViewHolder.mTransactionSeekBar.setBubbleColor(ContextCompat.getColor(mActivity, R.color.market_up));
//                    break;
//                case R.id.price_type_b://卖出
//                    mActivity.status = 1;
//
//                    mHeaderViewHolder.mTransactionSeekBar.setThumbColor(ContextCompat.getColor(mActivity, R.color.market_down));
//                    mHeaderViewHolder.mTransactionSeekBar.setSecondTrackColor(ContextCompat.getColor(mActivity, R.color.market_down));
//                    mHeaderViewHolder.mTransactionSeekBar.setBubbleColor(ContextCompat.getColor(mActivity, R.color.market_down));
//                    break;
//            }
//            upDate();
//        }
//
//        @OnClick({R.id.transction_decrease_price, R.id.transction_increase_price})
//        public void onViewClick(View view) {
//            switch (view.getId()) {
//
//                case R.id.transction_decrease_price:
//                    double price = Double.parseDouble(mHeaderViewHolder.mTransctionPriceEditText.getText().toString());
//                    String formata = mFormat.format(price + unitPrice);
//                    mCurrentPriceD = Double.valueOf(formata);
//                    mHeaderViewHolder.mTransctionPriceEditText.setText(formata);
//                    mHeaderViewHolder.mTransctionPriceEditText.setSelection(formata.length());
//                    break;
//                case R.id.transction_increase_price:
//                    if (mCurrentPriceD > unitPrice) {
//                        double price1 = Double.parseDouble(mHeaderViewHolder.mTransctionPriceEditText.getText().toString());
//                        String formatb = mFormat.format(price1 - unitPrice);
//                        mCurrentPriceD = Double.valueOf(formatb);
//                        mHeaderViewHolder.mTransctionPriceEditText.setText(formatb);
//                        mHeaderViewHolder.mTransctionPriceEditText.setSelection(formatb.length());
//                    }
//                    break;
//            }
//        }
//
//    }
//
//    private double formatDouble(Editable editable) {
//        String value = editable.toString().trim();
//        if (!CheckUtil.isOnlyPointNumber(value)) { //限制输入两位小数
////
//            if (value.indexOf(".") > 0) {
//                if (value.length() - value.indexOf(".") > 2) {
//                    editable.delete(value.indexOf(".") + 3, value.length());
//                }
//            }
//        }
//        value = editable.toString().trim();
//        return Double.valueOf(value);
//    }
//
//    /**
//     * 计算可以购买的最大数量
//     * wallet 钱包总金额
//     * mCurrentPriceD 当前价格
//     * leverage 杠杆
//     * shouPer 手续费率
//     * 计算公式 (wallet * leverage - 手续费) / mCurrentPriceD
//     */
//    private void calcuMostNum() {
//        maxNum = (Double.parseDouble(wallet)) / (mCurrentPriceD / leverage + mCurrentPriceD * shouPer);
//        maxNum = Math.floor(maxNum);
//        if (Double.isNaN(maxNum) || Double.isInfinite(maxNum)) {
//            maxNum = 0;
//        }
//    }
//
//    /**
//     * 计算总价格
//     * price 单价
//     * num 购买数量
//     * leverage 杠杆
//     * shouPer 手续费率
//     * 这里的数量 已经计算了手续费（ count = （wallet * 杠杆 - wallet * 手续费） / 单价 ）
//     * 计算公式 (price * num) / leverage
//     */
//    private double calcuAllPrice(double price, double num) {
//
//        return (price * num) / leverage + (price * num) * shouPer; //交易额 计算公式 : 最新价*购买数量/20
//    }
//
//    public static LevelTransactionFragment newInstance() {
//        LevelTransactionFragment fragment = new LevelTransactionFragment();
//        return fragment;
//    }
//
//    @Subscribe(code = Constants.USER_LOGOUT, threadMode = ThreadMode.MAIN)
//    public void logout() {
//        upDate();//初始化界面
//    }
//
//}
